package main
 
import (
    "fmt"
)
 
func counter(w chan<- int)  {
    defer close(w)

    for i := 0; i < 5; i++ {
        w <- i
    }
}

func printer(r <-chan int)  {
    for i := range r {
        fmt.Println(i)
    }
}

func main() {
    c := make(chan int)

    go counter(c)
    printer(c)

    fmt.Println("done")
}
